<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ taglib uri="http://www.opensymphony.com/sitemesh/decorator" prefix="decorator" %>
<%@ taglib uri="http://www.opensymphony.com/sitemesh/page" prefix="page" %>
<%@taglib prefix="sp" uri="http://www.springframework.org/tags" %>
<%@taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/functions" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <meta http-equiv="content-type" content="text/html; charset=utf-8"/>
    <title>${requestScope.data.systemsetting.name}-<decorator:title></decorator:title></title>
    <meta name="author" content="${requestScope.data.systemsetting.metaAuthor}"/>
    <meta name="copyright" content="${requestScope.data.systemsetting.metaCopyright}"/>
    <meta name="keywords" content="${requestScope.data.systemsetting.metaKeywords}"/>
    <meta name="description" content="${requestScope.data.systemsetting.metaDescription}"/>
    <link rel="icon" href="${requestScope.data.systemsetting.favicon}" type="image/x-icon"/>


    <link href="${pageContext.request.contextPath}/resources/shop/css/common.css" rel="stylesheet" type="text/css"/>
    <script type="text/javascript" src="${pageContext.request.contextPath}/resources/shop/js/jquery.js"></script>
    <script type="text/javascript" src="${pageContext.request.contextPath}/resources/shop/js/common.js"></script>
    <script type="text/javascript">
        $().ready(function () {

            var $headerLogin = $("#headerLogin");
            var $headerRegister = $("#headerRegister");
            var $headerUsername = $("#headerUsername");
            var $headerLogout = $("#headerLogout");
            var $productSearchForm = $("#productSearchForm");
            var $keyword = $("#productSearchForm input");
            var defaultKeyword = "商品搜索";

            var username = getCookie("username");
            if (username != null) {
                $headerUsername.text("您好, " + username).show();
                $headerLogout.show();
            } else {
                $headerLogin.show();
                $headerRegister.show();
            }

            $keyword.focus(function () {
                if ($keyword.val() == defaultKeyword) {
                    $keyword.val("");
                }
            });

            $keyword.blur(function () {
                if ($keyword.val() == "") {
                    $keyword.val(defaultKeyword);
                }
            });

            $productSearchForm.submit(function () {
                if ($.trim($keyword.val()) == "" || $keyword.val() == defaultKeyword) {
                    return false;
                }
            });

        });
    </script>
</head>
<body>

<div class="container header">
    <div class="span5">
        <div class="logo">
            <a href="${pageContext.request.contextPath}">
                <img src="${requestScope.data.systemsetting.logo}" alt="${requestScope.data.systemsetting.name}"
                     title="${requestScope.data.systemsetting.name}"/>
            </a>
        </div>
    </div>
    <div class="span9">
        <div class="headerAd">
            <c:forEach items="${requestScope.data.adMap.adposition}" var="adPostion">
                <c:if test="${adPostion.id==1}">
                    <c:forEach items="${requestScope.data.adMap.ads}" var="ad">
                        <c:if test="${ad.postion==adPostion.id}">
                            <a target="_blank" href="${ad.url}"><img src="${ad.path}" width="${adPostion.width}"
                                                                     height="${adPostion.height}"
                                                                     alt="${ad.content}" title="${ad.content}"/>
                            </a>
                        </c:if>
                    </c:forEach>
                </c:if>
            </c:forEach>
        </div>
    </div>
    <div class="span10 last">
        <div class="topNav clearfix">
            <ul>
                <li id="headerLogin" class="headerLogin">
                    <a href="/login.jhtml">登录</a> |
                </li>
                <li id="headerRegister" class="headerRegister">
                    <a href="/register.jhtml">注册</a> |
                </li>
                <li id="headerUsername" class="headerUsername"></li>
                <li id="headerLogout" class="headerLogout">
                    <a href="/logout.jhtml">[退出]</a> |
                </li>
                <c:forEach items="${requestScope.data.navigation.top}" var="item" varStatus="index">
                    <li>
                        <c:choose>
                            <c:when test="${item.isblanktarget}">
                                <a target="_blank" href="${item.url}">${item.name}</a>
                            </c:when>
                            <c:otherwise>
                                <a href="${item.url}">${item.name}</a>
                            </c:otherwise>
                        </c:choose>
                        <c:if test="${index.index<fn:length(requestScope.data.navigation.top)-1}">
                            |
                        </c:if>
                    </li>
                </c:forEach>
            </ul>
        </div>
        <div class="cart">
            <a href="/cart/list.jhtml">购物车</a>
        </div>
        <div class="phone">
            <sp:message code="service.hotline"/>:
            <strong>${requestScope.data.systemsetting.phone}</strong>
        </div>
    </div>
    <div class="span24">
        <ul class="mainNav">
            <c:forEach items="${requestScope.data.navigation.main}" var="item" varStatus="index">
                <li>
                    <c:choose>
                        <c:when test="${item.isblanktarget}">
                            <a target="_blank" href="${item.url}">${item.name}</a>
                        </c:when>
                        <c:otherwise>
                            <a href="${item.url}">${item.name}</a>
                        </c:otherwise>
                    </c:choose>
                    <c:if test="${index.index<fn:length(requestScope.data.navigation.main)-1}">
                        |
                    </c:if>
                </li>
            </c:forEach>
        </ul>
    </div>
    <div class="span24">
        <div class="tagWrap">
            <ul class="tag">
                <li class="icon"
                    style="background: url(${pageContext.request.contextPath}/resources/images/hot.gif) right no-repeat;">
                    <a href="/product/list.jhtml?tagIds=1">热销</a>
                </li>
                <li class="icon"
                    style="background: url(${pageContext.request.contextPath}/resources/images/new.gif) right no-repeat;">
                    <a href="/product/list.jhtml?tagIds=2">最新</a>
                </li>
            </ul>
            <div class="hotSearch">
                热门搜索:
                <c:forEach items="${requestScope.data.hotSearches}" var="item">
                    <a href="">${item}</a>
                </c:forEach>
            </div>
            <div class="search">
                <form id="productSearchForm" action="/product/search.jhtml" method="get">
                    <input name="keyword" class="keyword" value="商品搜索" maxlength="30"/>
                    <button type="submit">搜索</button>
                </form>
            </div>
        </div>
    </div>
</div>
<div>
<decorator:body></decorator:body>
</div>
<div class="container footer">
    <div class="span24">
        <div class="footerAd">
            <c:forEach items="${requestScope.data.adMap.adposition}" var="adPostion">
                <c:if test="${adPostion.id==2}">
                    <c:forEach items="${requestScope.data.adMap.ads}" var="ad">
                        <c:if test="${ad.postion==adPostion.id}">
                            <a target="_blank" href="${ad.url}"> <img src="${ad.path}" width="${adPostion.width}"
                                                                      height="${adPostion.height}"
                                                                      alt="${ad.content}" title="${ad.content}"/>
                            </a>
                        </c:if>
                    </c:forEach>
                </c:if>
            </c:forEach>
        </div>
    </div>
    <div class="span24">
        <ul class="bottomNav">
            <c:forEach items="${requestScope.data.navigation.foot}" var="item" varStatus="index">
                <li>
                    <c:choose>
                        <c:when test="${item.isblanktarget}">
                            <a target="_blank" href="${item.url}">${item.name}</a>
                        </c:when>
                        <c:otherwise>
                            <a href="${item.url}">${item.name}</a>
                        </c:otherwise>
                    </c:choose>
                    <c:if test="${index.index<fn:length(requestScope.data.navigation.foot)-1}">
                        |
                    </c:if>
                </li>
            </c:forEach>
        </ul>
    </div>
    <div class="span24">
        <div class="copyright">${requestScope.data.systemsetting.copyright}</div>
    </div>
</div>
</body>
</html>